package org.student.service.impl;

import java.util.List;

import org.student.Iservice.IStudentService;
import org.student.dao.IStudentDao;
import org.student.dao.impl.StudentDaoimpl;
import org.student.entity.Student;



public class StudentServiceimpl implements IStudentService{	
	
	IStudentDao studentdao = new StudentDaoimpl();
	  public   int addstudent(Student student) {
		     
		     if(!studentdao.isExist(student.getSon())) {
		    	return studentdao.AddStudent(student);		    	 
		     }
		     else{
		    	 return 0;
		     }
	  }
	  public  Student querystudentbyson(int son) {
		  if(studentdao.isExist(son)) {
			  return studentdao.QueryStudentBySon(son);
		  }
		  else {
			  return null;
		  }
	  }
	  public  List<Student> queryallstudent(){
		  return studentdao.QueryAllStudent();
	  }
	  public  int  deletestudent(Student student,int son) {
		  if(studentdao.isExist(student.getSon())) {
		    	return studentdao.DeleteStudentBySon(son);		    	 
		     }
		     else{
		    	 return 0;
		     }
	  }
	  public  int  updatestudent(Student student,int son) {
		  if(studentdao.isExist(son)) {
		    return studentdao.UpdateStudentBySon(student,son);			
		     }
		     else{
		    	 return 0;
		     }
	  }
	@Override
	public int getTotalCount() {
	 return	studentdao.GetTotalCount();	
	}
	@Override
	public List<Student> queryStudentByPage(int currentPage, int pageSize) {
	  return  studentdao.queryStudentByPage(currentPage, pageSize);
		
	}
}
